/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.cotec.model;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author magalhaes
 */
@Entity
@Table(name = "sala")
@NamedQueries({@NamedQuery(name = "Sala.findAll", query = "SELECT s FROM Sala s"), @NamedQuery(name = "Sala.findById", query = "SELECT s FROM Sala s WHERE s.id = :id"), @NamedQuery(name = "Sala.findByNome", query = "SELECT s FROM Sala s WHERE s.nome = :nome"), @NamedQuery(name = "Sala.findByIdentificacao", query = "SELECT s FROM Sala s WHERE s.identificacao = :identificacao")})
public class Sala implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "nome", length=45)
    private String nome;
    @Column(name = "identificacao", length=45)
    private String identificacao;
    @JoinColumn(name = "setor", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Setor setor;

    public Sala() {
    	this.setSetor(new Setor());
    }

    public Sala(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getIdentificacao() {
        return identificacao;
    }

    public void setIdentificacao(String identificacao) {
        this.identificacao = identificacao;
    }

    public Setor getSetor() {
        return setor;
    }

    public void setSetor(Setor setor) {
        this.setor = setor;
    }

//    public Collection<Posicao> getPosicaoCollection() {
//        return posicaoCollection;
//    }
//
//    public void setPosicaoCollection(Collection<Posicao> posicaoCollection) {
//        this.posicaoCollection = posicaoCollection;
//    }

    @Override
    public String toString() {
        return "br.com.cotec.model.Sala[id=" + id + "]";
    }

    
	@Override
	public boolean equals(Object object) {
		if (!(object instanceof Sala)) {
			return false;
		}
		Sala other = (Sala) object;
		String este = ""+this.id+this.identificacao+this.nome;
		String outro = ""+other.getId()+other.getIdentificacao()+other.getNome();
		return este.equalsIgnoreCase(outro);
	}
	
	@Override
	public int hashCode() {
		String aux = ""+this.id+this.identificacao+this.nome;
		return aux.hashCode();
	}
}
